<?php
 /***************************************************************
 * Mor-MVC Framework, A framework that can easily let you build a powerful
 * and scalable web application based on PHP language,
 * this framewrok is a copy of the Zend Behavior Framework
 *  Copyright (C) 2010  Nabil Droussi <nabildroussi@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***************************************************************/
final class ClassLoader
{
	public static function load($className,$extension = "php", $directory = "")
	{
		$includePath = Registry::getItem("INCLUDE_PATH");
		if($directory == "" && isset($includePath))
			$directory = Registry::getItem("INCLUDE_PATH");
		$classPath = $directory."/".str_replace("_","/",$className).".{$extension}";

		if(!is_dir($directory))
			throw new Exception("Invalid class path.");
		
		if(!is_file($classPath))
			throw new Exception("The class file {$className} don't exist.");
			
		require_once($classPath);
	}
}
?>